home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / qfiles.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  10.5 KB  |  457 lines

  1.  
  2. //
  3. // qfiles.h: quake file formats
  4. // This file must be identical in the quake and utils directories
  5. //
  6.  
  7. /*
  8. ========================================================================
  9.  
  10. .MD2 triangle model file format
  11.  
  12. ========================================================================
  13. */
  14.  
  15. #define IDALIASHEADER        (('2'<<24)+('P'<<16)+('D'<<8)+'I')
  16. #define ALIAS_VERSION    8
  17.  
  18. #define    MAX_TRIANGLES    4096
  19. #define MAX_VERTS        2048
  20. #define MAX_FRAMES        512
  21. #define MAX_MD2SKINS    32
  22. #define    MAX_SKINNAME    64
  23.  
  24. typedef struct
  25. {
  26.     short    s;
  27.     short    t;
  28. } dstvert_t;
  29.  
  30. typedef struct 
  31. {
  32.     short    index_xyz[3];
  33.     short    index_st[3];
  34. } dtriangle_t;
  35.  
  36. typedef struct
  37. {
  38.     byte    v[3];            // scaled byte to fit in frame mins/maxs
  39.     byte    lightnormalindex;
  40. } dtrivertx_t;
  41.  
  42. typedef struct
  43. {
  44.     float        scale[3];    // multiply byte verts by this
  45.     float        translate[3];    // then add this
  46.     char        name[16];    // frame name from grabbing
  47.     dtrivertx_t    verts[1];    // variable sized
  48. } daliasframe_t;
  49.  
  50.  
  51. // the glcmd format:
  52. // a positive integer starts a tristrip command, followed by that many
  53. // vertex structures.
  54. // a negative integer starts a trifan command, followed by -x vertexes
  55. // a zero indicates the end of the command list.
  56. // a vertex consists of a floating point s, a floating point t,
  57. // and an integer vertex index.
  58.  
  59.  
  60. typedef struct
  61. {
  62.     int            ident;
  63.     int            version;
  64.  
  65.     int            skinwidth;
  66.     int            skinheight;
  67.     int            framesize;        // byte size of each frame
  68.  
  69.     int            num_skins;
  70.     int            num_xyz;
  71.     int            num_st;            // greater than num_xyz for seams
  72.     int            num_tris;
  73.     int            num_glcmds;        // dwords in strip/fan command list
  74.     int            num_frames;
  75.  
  76.     int            ofs_skins;        // each skin is a MAX_SKINNAME string
  77.     int            ofs_st;            // byte offset from start for stverts
  78.     int            ofs_tris;        // offset for dtriangles
  79.     int            ofs_frames;        // offset for first frame
  80.     int            ofs_glcmds;    
  81.     int            ofs_end;        // end of file
  82.  
  83. } dmdl_t;
  84.  
  85. #define MD3_IDENT            (('3'<<24)+('P'<<16)+('D'<<8)+'I')
  86. #define    MAX_QPATH            64        // max length of a quake game pathname
  87. #define    MD3_XYZ_SCALE        (1.0/64)
  88.  
  89. typedef struct {
  90.     int            ident;
  91.     int            version;
  92.  
  93.     char        name[MAX_QPATH];    // model name
  94.  
  95.     int            flags;
  96.  
  97.     int            numFrames;
  98.     int            numTags;            
  99.     int            numSurfaces;
  100.  
  101.     int            numSkins;
  102.  
  103.     int            ofsFrames;            // offset for first frame
  104.     int            ofsTags;            // numFrames * numTags
  105.     int            ofsSurfaces;        // first surface, others follow
  106.  
  107.     int            ofsEnd;                // end of file
  108. } md3Header_t;
  109.  
  110. typedef struct {
  111.     int        ident;                // 
  112.  
  113.     char    name[MAX_QPATH];    // polyset name
  114.  
  115.     int        flags;
  116.     int        numFrames;            // all surfaces in a model should have the same
  117.  
  118.     int        numShaders;            // all surfaces in a model should have the same
  119.     int        numVerts;
  120.  
  121.     int        numTriangles;
  122.     int        ofsTriangles;
  123.  
  124.     int        ofsShaders;            // offset from start of md3Surface_t
  125.     int        ofsSt;                // texture coords are common for all frames
  126.     int        ofsXyzNormals;        // numVerts * numFrames
  127.  
  128.     int        ofsEnd;                // next surface follows
  129.  
  130. } md3Surface_t;
  131.  
  132. typedef struct {
  133.     char            name[MAX_QPATH];
  134.     int                shaderIndex;    // for in-game use
  135. } md3Shader_t;
  136.  
  137. typedef struct {
  138.     int            indexes[3];
  139. } md3Triangle_t;
  140.  
  141. typedef struct {
  142.     float        st[2];
  143. } md3St_t;
  144.  
  145. typedef struct {
  146.     short        xyz[3];
  147.     short        normal;
  148. } md3XyzNormal_t;
  149.  
  150.  
  151. typedef struct
  152. {
  153.   float st[2];
  154.   int   nVertIndex;
  155. } glst_t;
  156.  
  157. typedef struct
  158. {
  159.   int     nCount;
  160.   int     ObjectIndex;
  161.   glst_t  GlSt;
  162. } gl_t;
  163.  
  164. /*
  165. ========================================================================
  166.  
  167. .SP2 sprite file format
  168.  
  169. ========================================================================
  170. */
  171.  
  172. #define IDSPRITEHEADER    (('2'<<24)+('S'<<16)+('D'<<8)+'I')
  173.         // little-endian "IDS2"
  174. #define SPRITE_VERSION    2
  175.  
  176. typedef struct
  177. {
  178.     int        width, height;
  179.     int        origin_x, origin_y;        // raster coordinates inside pic
  180.     char    name[MAX_SKINNAME];        // name of pcx file
  181. } dsprframe_t;
  182.  
  183. typedef struct {
  184.     int            ident;
  185.     int            version;
  186.     int            numframes;
  187.     dsprframe_t    frames[1];            // variable sized
  188. } dsprite_t;
  189.  
  190. /*
  191. ==============================================================================
  192.  
  193.   .WAL texture file format
  194.  
  195. ==============================================================================
  196. */
  197.  
  198.  
  199. #define    MIPLEVELS    4
  200. typedef struct miptex_s
  201. {
  202.     char        name[32];
  203.     unsigned    width, height;
  204.     unsigned    offsets[MIPLEVELS];        // four mip maps stored
  205.     char        animname[32];            // next frame in animation chain
  206.     int            flags;
  207.     int            contents;
  208.     int            value;
  209. } miptex_t;
  210.  
  211.  
  212.  
  213. /*
  214. ==============================================================================
  215.  
  216.   .BSP file format
  217.  
  218. ==============================================================================
  219. */
  220.  
  221. #define IDBSPHEADER    (('P'<<24)+('S'<<16)+('B'<<8)+'I')
  222.         // little-endian "IBSP"
  223.  
  224. #define BSPVERSION    36
  225.  
  226.  
  227. // upper design bounds
  228. // leaffaces, leafbrushes, planes, and verts are still bounded by
  229. // 16 bit short limits
  230. #define    MAX_MAP_MODELS        1024
  231. #define    MAX_MAP_BRUSHES        8192
  232. #define    MAX_MAP_ENTITIES    2048
  233. #define    MAX_MAP_ENTSTRING    0x20000
  234. #define    MAX_MAP_TEXINFO        8192
  235.  
  236. #define    MAX_MAP_PLANES        65536
  237. #define    MAX_MAP_NODES        65536
  238. #define    MAX_MAP_BRUSHSIDES    65536
  239. #define    MAX_MAP_LEAFS        65536
  240. #define    MAX_MAP_VERTS        65536
  241. #define    MAX_MAP_FACES        65536
  242. #define    MAX_MAP_LEAFFACES    65536
  243. #define    MAX_MAP_LEAFBRUSHES 65536
  244. #define    MAX_MAP_PORTALS        65536
  245. #define    MAX_MAP_EDGES        128000
  246. #define    MAX_MAP_SURFEDGES    256000
  247. #define    MAX_MAP_LIGHTING    0x200000
  248. #define    MAX_MAP_VISIBILITY    0x100000
  249.  
  250. #define MAX_BRUSH_SIZE 8192
  251.  
  252. // key / value pair sizes
  253.  
  254. #define    MAX_KEY        32
  255. #define    MAX_VALUE    1024
  256.  
  257. //=============================================================================
  258.  
  259. typedef struct
  260. {
  261.     int        fileofs, filelen;
  262. } lump_t;
  263.  
  264. #define    LUMP_ENTITIES        0
  265. #define    LUMP_PLANES            1
  266. #define    LUMP_VERTEXES        2
  267. #define    LUMP_VISIBILITY        3
  268. #define    LUMP_NODES            4
  269. #define    LUMP_TEXINFO        5
  270. #define    LUMP_FACES            6
  271. #define    LUMP_LIGHTING        7
  272. #define    LUMP_LEAFS            8
  273. #define    LUMP_LEAFFACES        9
  274. #define    LUMP_LEAFBRUSHES    10
  275. #define    LUMP_EDGES            11
  276. #define    LUMP_SURFEDGES        12
  277. #define    LUMP_MODELS            13
  278. #define    LUMP_BRUSHES        14
  279. #define    LUMP_BRUSHSIDES        15
  280. #define    LUMP_POP            16
  281.  
  282. #define    HEADER_LUMPS        17
  283.  
  284. typedef struct
  285. {
  286.     int            ident;
  287.     int            version;    
  288.     lump_t        lumps[HEADER_LUMPS];
  289. } dheader_t;
  290.  
  291. typedef struct
  292. {
  293.     float        mins[3], maxs[3];
  294.     float        origin[3];        // for sounds or lights
  295.     int            headnode;
  296.     int            firstface, numfaces;    // submodels just draw faces
  297.                                         // without walking the bsp tree
  298. } dmodel_t;
  299.  
  300.  
  301. typedef struct
  302. {
  303.     float    point[3];
  304. } dvertex_t;
  305.  
  306.  
  307. // 0-2 are axial planes
  308. #define    PLANE_X            0
  309. #define    PLANE_Y            1
  310. #define    PLANE_Z            2
  311.  
  312. // 3-5 are non-axial planes snapped to the nearest
  313. #define    PLANE_ANYX        3
  314. #define    PLANE_ANYY        4
  315. #define    PLANE_ANYZ        5
  316.  
  317. // planes (x&~1) and (x&~1)+1 are allways opposites
  318.  
  319. typedef struct
  320. {
  321.     float    normal[3];
  322.     float    dist;
  323.     int        type;        // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
  324. } dplane_t;
  325.  
  326.  
  327. // contents flags are seperate bits
  328. // a given brush can contribute multiple content bits
  329. // multiple brushes can be in a single leaf
  330.  
  331. // lower bits are stronger, and will eat weaker brushes completely
  332. #define    CONTENTS_SOLID            1        // an eye is never valid in a solid
  333. #define    CONTENTS_WINDOW            2        // translucent, but not watery
  334. #define    CONTENTS_AUX            4
  335. #define    CONTENTS_LAVA            8
  336. #define    CONTENTS_SLIME            16
  337. #define    CONTENTS_WATER            32
  338. #define    CONTENTS_MIST            64
  339. #define    LAST_VISIBLE_CONTENTS    64
  340.  
  341. // remaining contents are non-visible, and don't eat brushes
  342. #define    CONTENTS_PLAYERCLIP        0x10000
  343. #define    CONTENTS_MONSTERCLIP    0x20000
  344.  
  345. // currents can be added to any other contents, and may be mixed
  346. #define    CONTENTS_CURRENT_0        0x40000
  347. #define    CONTENTS_CURRENT_90        0x80000
  348. #define    CONTENTS_CURRENT_180    0x100000
  349. #define    CONTENTS_CURRENT_270    0x200000
  350. #define    CONTENTS_CURRENT_UP        0x400000
  351. #define    CONTENTS_CURRENT_DOWN    0x800000
  352.  
  353. #define    CONTENTS_ORIGIN                0x1000000      // removed before bsping an entity
  354.  
  355. #define    CONTENTS_MONSTER            0x2000000      // should never be on a brush, only in game
  356. #define    CONTENTS_DEADMONSTER      0x4000000   // corpse
  357. #define    CONTENTS_DETAIL                0x8000000      // brushes to be added after vis leafs
  358. #define    CONTENTS_TRANSLUCENT      0x10000000    // auto set if any surface has trans
  359. #define    CONTENTS_LADDER         0x20000000    // ladder
  360. #define    CONTENTS_NEGATIVE_CURVE 0x40000000    // reverse inside / outside
  361.  
  362. #define    CONTENTS_KEEP    (CONTENTS_DETAIL | CONTENTS_NEGATIVE_CURVE)
  363.  
  364.  
  365. typedef struct
  366. {
  367.     int            planenum;
  368.     int            children[2];    // negative numbers are -(leafs+1), not nodes
  369.     short        mins[3];        // for frustom culling
  370.     short        maxs[3];
  371.     unsigned short    firstface;
  372.     unsigned short    numfaces;    // counting both sides
  373. } dnode_t;
  374.  
  375.  
  376. typedef struct texinfo_s
  377. {
  378.     float        vecs[2][4];        // [s/t][xyz offset]
  379.     int            flags;            // miptex flags + overrides
  380.     int            value;            // light emission, etc
  381.     char        texture[32];    // texture name (textures/*.wal)
  382.     int            nexttexinfo;    // for animations, -1 = end of chain
  383. } texinfo_t;
  384.  
  385.  
  386. #define    SURF_LIGHT        0x1        // value will hold the light strength
  387.  
  388. #define    SURF_SLICK        0x2        // effects game physics
  389.  
  390. #define    SURF_SKY        0x4        // don't draw, but add to skybox
  391. #define    SURF_WARP        0x8        // turbulent water warp
  392. #define    SURF_TRANS33    0x10
  393. #define    SURF_TRANS66    0x20
  394. #define    SURF_FLOWING    0x40    // scroll towards angle
  395. #define    SURF_NODRAW        0x80    // don't bother referencing the texture
  396.  
  397. #define SURF_PATCH        0x20000000
  398. #define    SURF_CURVE_FAKE        0x40000000
  399. #define    SURF_CURVE            0x80000000
  400. #define    SURF_KEEP        (SURF_CURVE | SURF_CURVE_FAKE | SURF_PATCH)
  401.  
  402. // note that edge 0 is never used, because negative edge nums are used for
  403. // counterclockwise use of the edge in a face
  404. typedef struct
  405. {
  406.     unsigned short    v[2];        // vertex numbers
  407. } dedge_t;
  408.  
  409. #define    MAXLIGHTMAPS    4
  410. typedef struct
  411. {
  412.     unsigned short    planenum;
  413.     short        side;
  414.  
  415.     int            firstedge;        // we must support > 64k edges
  416.     short        numedges;    
  417.     short        texinfo;
  418.  
  419. // lighting info
  420.     byte        styles[MAXLIGHTMAPS];
  421.     int            lightofs;        // start of [numstyles*surfsize] samples
  422. } dface_t;
  423.  
  424. typedef struct
  425. {
  426.     int            contents;            // OR of all brushes (not needed?)
  427.  
  428.     int            pvsofs;                // -1 = no info
  429.     int            phsofs;                // -1 = no info
  430.  
  431.     short        mins[3];            // for frustum culling
  432.     short        maxs[3];
  433.  
  434.     unsigned short        firstleafface;
  435.     unsigned short        numleaffaces;
  436.  
  437.     unsigned short        firstleafbrush;
  438.     unsigned short        numleafbrushes;
  439. } dleaf_t;
  440.  
  441. typedef struct
  442. {
  443.     unsigned short    planenum;        // facing out of the leaf
  444.     short    texinfo;
  445. } dbrushside_t;
  446.  
  447. typedef struct
  448. {
  449.     int            firstside;
  450.     int            numsides;
  451.     int            contents;
  452. } dbrush_t;
  453.  
  454. #define    ANGLE_UP    -1
  455. #define    ANGLE_DOWN    -2
  456.  
  457.